<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>报告单详情</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<meta http-equiv="expires" content="0">
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<link href="../../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="../../css/reset.css" />
		<link rel="stylesheet" href="../../css/cmms.css" />
		<link rel="stylesheet" href="../../css/iconfont.css" />
		<link rel="stylesheet" href="../../css/patient/reportDetail.css" />
		<link rel="stylesheet" type="text/css" href="../../css/patient/preview.css"/>
		<script src="../../js/vconsole.min.js"></script>
	</head>

	<body>
		<div id="reportDetail" v-cloak>
			<div class="wrap">
				<div class="top">
					<p><span>{{sampleResult.Operator}}</span><span class="right" @tap="lookPDF"> 报告单</span></p>
					<p>条形码：{{sampleResult.Barcode}}</p>
					<p><span>检测时间：{{sampleResult.TestTime}}</span><span>结果时间：{{sampleResult.ResultTime}}</span></p>
				</div>
				<div class="main" :class="{'hidden':!isShow}">
					<ul>
						<li class="mui-table-view-cell">
							<span>项目名称</span>
							<span>结果</span>
							<span>参考值</span>
							<span>单位</span>
						</li>
						<li class="mui-table-view-cell" v-for="samp in sampleItems">
							<span>{{samp.ItemName?samp.ItemName:'/'}}</span>
							<span>{{samp.TestResult?samp.TestResult:'/'}}</span>
							<span>{{samp.ReferenceValue?samp.ReferenceValue:'/'}}</span>
							<span>{{samp.UnitName?samp.UnitName:'/'}}</span>
						</li>
					</ul>
				</div>
				<div class="reportImg" v-cloak :class="{'hidden':isShow}">
					<div class="mask">
						<div class="title">
							<span>报告单(点击小图可预览大图)</span>
							<i class="icon iconfont icon-shanchu" @tap="isShow=true"></i>
						</div>
						<div class="explanationDetail">
							<span><img id="headImg" class="headPic"  :src="imgSrcs" :data-preview-src="imgSrcs" data-preview-group="1" data-content="这里是文字说明"></span>
						</div>
					</div>
				</div>
			</div>
		</div>
		<script src="../../js/mui.min.js"></script>
		<script src="../../js/mui.zoom.js?time=654323"></script>
		<script src="../../js/mui.previewimage.js?time=333"></script>
		<script src="../../js/vue.js"></script>
		<script src="https://res2.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
		<script src="../../js/jquery-2.1.4.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/cmms.js?time=333"></script>
		<script type="text/javascript">
			mui.init()
		</script>
		<script type="text/javascript">
			mui.previewImage();
			new Vue({
				el:"#reportDetail",
				data:{
					SampleInfoId:'',//样本id
					HospitalCode:'',//医院名称
					Token:'',
					sampleResult:[],//样本结果详情
					sampleItems:[],//样本条目
					id:0,
					isShow:true,
					imgSrcs:''
				},
				mounted(){
//					var vConsole = new VConsole();
					this.getUrl();
					this.loadInfo();
				},
				methods:{
					/*获取URI后的HospitalCode和SampleInfoId*/
					getUrl(){
						let _this=this;
						var url = location.search; //获取url中"?"符后的字串    
						var theRequest = new Object();  
//						console.log(url);
					   	if (url.indexOf("?") != -1) {   
					      var str = url.substr(1);  
//					      console.log(str);
					      strs = str.split("&");  
					      for(var i = 0; i < strs.length; i ++) {   
					         theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);   
					      } 
					   	}   
//					   	console.log(theRequest);
					   	_this.HospitalCode = theRequest.HospitalCode;
					   	_this.SampleInfoId = theRequest.SampleInfoId;
					   	_this.id = theRequest.sid;
					   	
					   	console.log(_this.HospitalCode);
					   	console.log(_this.SampleInfoId);
					   	console.log(_this.id);
					  },
					/*加载报告详情页*/
					loadInfo(){
						let _this = this;
						_this.Token = localStorage.getItem('hospi_token');
						$.ajax({
					   		type:"get",
					   		url:"https://antreport.ulabmed.com:8081/ReportAshx/ReportHandler.ashx",
					   		async:true,
					   		data:{
					   			action:'GetSampleResult',
					   			SampleInfoId:_this.SampleInfoId,
								HospitalCode:_this.HospitalCode,
								Token:_this.Token,
								jsonpCallback:"cb"
					   		},
					   		dataType:"jsonp",
					   		success:function(data){
					   			console.log(data[0].Msg);
					   			mui.toast(data[0].Msg);
					   			var data = data[0];
					   			_this.sampleResult = data.Value.SampleResult[0];
					   			_this.sampleItems = data.Value.SampleResult;
					   		},
					   		error:function(err){
					   			console.log(err)
					   		}
					   });
					},
					lookPDF(){
						let _this = this;
//						_this.Token = localStorage.getItem('hospi_token');
						_this.isShow=false;
						$.ajax({
					   		type:"get",
					   		url:"https://antreport.ulabmed.com:8081/ReportAshx/ReportHandler.ashx",
					   		async:true,
					   		data:{
					   			action:'ShowReport',
					   			ID:_this.id,
								HospitalCode:_this.HospitalCode,
								ReportTopType:'',
								RptBusinessType:'',
								Token:_this.Token,
								jsonpCallback:"cb"
					   		},
					   		dataType:"jsonp",
					   		success:function(data){
					   			console.log(data[0].Msg);
					   			mui.toast(data[0].Msg);
					   			_this.imgSrcs = "http://27.153.224.130:8081/ReportAshx/"+data[0].Value;
					   			console.log(_this.imgSrcs);
					   		},
					   		error:function(err){
					   			console.log(err)
					   		}
					   });
					}
				}
			})
		</script>
	</body>

</html>